Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support actor isolated and existential any. #563

Merged
merged 4 commits into from
Apr 6, 2024

Conversation

noppefoxwolf
Copy link
Contributor

No description provided.

@TimOliver
Copy link
Owner

Thanks for the PR @noppefoxwolf! Admittedly I'm still new to Swift concurrency; why is this required?

It would require bumping the minimum version of this library to iOS 12, and I'm still trying to aim to support iOS 11... 😅

@noppefoxwolf
Copy link
Contributor Author

I fixed platform version because deprecated. But it's not related my changes.
So, I reverted code.

See also: https://developer.apple.com/documentation/packagedescription/supportedplatform/iosversion/v9

@noppefoxwolf
Copy link
Contributor Author

Actor isolation is introduced by Swift5.5.
https://github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md

The actor is clarify where function called what thread.
In default, Delegator doesn't know actor.
So, It should call with Task method even if delegate called from main thread.

protocol Delegate {
  func onTap()
}

extension ViewController: Delegate {
  func onTap() {
    Task {
      await self.updateBackgroundColor()
    }
  }
}

If all delegate method called from main thread, protocol is prefer to have @mainactor.
Delegators no longer need to write Task or self.

@MainActor protocol Delegate {
  func onTap()
}

extension ViewController: Delegate {
  func onTap() {
    updateBackgroundColor()
  }
}

@TimOliver TimOliver merged commit 4f9cee3 into TimOliver:main Apr 6, 2024
@TimOliver
Copy link
Owner

Ahhh I see! No problems then! I'll double check it still works with iOS 11 and merge it in.

Thanks so much for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants